/* eslint-disable */
// @ts-ignore
import request from '@/utils/request';
import { CustomRequestOptions } from '@/interceptors/request';

import * as API from './types';

/** 绑定分销商户账户 POST /tourism/client/c/user/bindFzUser */
export async function bindFzUserUsingPost({
  body,
  options,
}: {
  body: API.ClientUserFzBindParam;
  options?: CustomRequestOptions;
}) {
  return request<API.CommonResultBoolean_>(
    '/tourism/client/c/user/bindFzUser',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
      ...(options || {}),
    }
  );
}

/** 生成小程序码 POST /tourism/client/c/user/generateWxaQrCode */
export async function generateWxaQrCodeUsingPost({
  body,
  options,
}: {
  body: API.WxQrCodeParam;
  options?: CustomRequestOptions;
}) {
  return request<API.CommonResultString_>(
    '/tourism/client/c/user/generateWxaQrCode',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
      ...(options || {}),
    }
  );
}

/** 生成小程序码 POST /tourism/client/c/user/generateWxaQrCode */
export async function generateWxaQrCodeUsingPost2({
  body,
  options,
}: {
  body: API.WxQrCodeParam;
  options?: CustomRequestOptions;
}) {
  return request<API.CommonResultString_>(
    '/tourism/client/c/user/generateWxaQrCode2',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
      ...(options || {}),
    }
  );
}

/** 获取用户信息 GET /tourism/client/c/user/getUserInfo */
export async function getUserInfoUsingGet({
  options,
}: {
  options?: CustomRequestOptions;
}) {
  return request<API.CommonResultClientUser_>(
    '/tourism/client/c/user/getUserInfo',
    {
      method: 'GET',
      ...(options || {}),
    }
  );
}

/** 登录 POST /tourism/client/c/user/login */
export async function loginUsingPost({
  body,
  options,
}: {
  body: API.ClientUserLoginParam;
  options?: CustomRequestOptions;
}) {
  return request<API.CommonResultString_>('/tourism/client/c/user/login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 退出 POST /tourism/client/c/user/logout */
export async function logoutUsingPost({
  options,
}: {
  options?: CustomRequestOptions;
}) {
  return request<API.CommonResultString_>('/tourism/client/c/user/logout', {
    method: 'POST',
    ...(options || {}),
  });
}

/** 注册 POST /tourism/client/c/user/register */
export async function addUsingPost({
  body,
  options,
}: {
  body: API.ClientUserAddParam;
  options?: CustomRequestOptions;
}) {
  return request<API.CommonResultString_>('/tourism/client/c/user/register', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 修改用户信息 POST /tourism/client/c/user/updateUserInfo */
export async function updateUserInfoUsingPost({
  body,
  options,
}: {
  body: API.ClientUserEditParam;
  options?: CustomRequestOptions;
}) {
  return request<API.CommonResultString_>(
    '/tourism/client/c/user/updateUserInfo',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
      ...(options || {}),
    }
  );
}

/** 上传头像 POST /tourism/client/c/user/uploadAvatar */
export async function uploadDynamicReturnUrlUsingPost({
  body,
  file,
  options,
}: {
  body: {};
  file?: File;
  options?: CustomRequestOptions;
}) {
  const formData = new FormData();

  if (file) {
    formData.append('file', file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as { [key: string]: any })[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });

  return request<API.CommonResultString_>(
    '/tourism/client/c/user/uploadAvatar',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'multipart/form-data',
      },
      data: formData,
      ...(options || {}),
    }
  );
}

/** 微信小程序登录 POST /tourism/client/c/user/wxMaLogin */
export async function wxMaLoginUsingPost({
  body,
  options,
}: {
  body: API.WxMaLoginParam;
  options?: CustomRequestOptions;
}) {
  return request<API.CommonResultString_>('/tourism/client/c/user/wxMaLogin', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
